package com.worldtolearn.offer.dao;

import java.util.List;

import javax.annotation.Resource;
import javax.inject.Named;

import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.PropertySource;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import com.worldtolearn.offer.entity.SupplierOffer;


@Repository
public class SupplierOfferDao extends HibernateDaoSupport implements ISupplierOfferDao {
	
	
	@Autowired
	public void init(SessionFactory factory) {
	    setSessionFactory(factory);
	}
	
	
	@Override
	public void createSupplierOffer(SupplierOffer supplierOffer) {
		
		System.out.println("SupplierOfferDao createSupplierOffer - Save Description-");
		getHibernateTemplate().save(supplierOffer.getDescription());
		
		System.out.println("SupplierOfferDao createSupplierOffer - Save Adsress-");
		getHibernateTemplate().save(supplierOffer.getAdress());
		
		System.out.println("SupplierOfferDao createSupplierOffer - Save Activity-");
		getHibernateTemplate().save(supplierOffer.getActivity());
		
		System.out.println("SupplierOfferDao createSupplierOffer - Save SupplierOffer-");
		getHibernateTemplate().save(supplierOffer);
		
	}

	@Override
	public void deleteSupplierOffer(SupplierOffer supplierOffer) {
		getHibernateTemplate().delete(supplierOffer);
		
	}

	@Override
	public List<SupplierOffer> getAllSupplierOffer() {
		return getHibernateTemplate().find("from SupplierOffer");
	}

	@Override
	public List<SupplierOffer> getSupplierOfferByActivity(String activity) {
		return null;
	}

}
